package cn.gcjxsc.common.consts;

/**
 * 支付通道
 *
 * @author pumbaa
 * @since 1.0
 */
public enum PayChannel {
    OTHER,
    /**
     * 余额
     */
    ACCOUNT,
    /**
     * 支付宝
     */
    ALIPAY,
    /**
     * 微信
     */
    WECHAT,
    /**
     * 银联
     */
    UNIONPAY,
    /**
     * 到付
     */
    COLLECTED;

    public static PayChannel fromCode(int channel) {
        PayChannel[] values = PayChannel.values();
        for (PayChannel value : values) {
            if (value.ordinal() == channel) {
                return value;
            }
        }
        return null;
    }

    public static PayChannel fromName(String name) {
        PayChannel[] values = PayChannel.values();
        for (PayChannel value : values) {
            if (value.name().equalsIgnoreCase(name)) {
                return value;
            }
        }
        return null;
    }
}
